//! 网络服务错误定义

use thiserror::Error;
use nacos_core::NacosError;

#[derive(Debug, Error)]
pub enum NetworkError {
    #[error("连接超时")]
    Timeout,

    #[error("连接被拒绝")]
    ConnectionRefused,

    #[error("请求序列化失败: {0}")]
    Serialization(String),

    #[error("响应反序列化失败: {0}")]
    Deserialization(String),

    #[error("网络 I/O 错误: {0}")]
    Io(String),
}

impl From<NetworkError> for NacosError {
    fn from(err: NetworkError) -> Self {
        NacosError::Network(err.to_string())
    }
}
